package com.zis.system.controller;

import com.zis.starter.core.ResponseEntity;
import com.zis.system.inter.IRegionInter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Create by wangshen 2018/5/28
 */
@RestController
@RequestMapping("/region")
public class RegionController {

    @Autowired
    private IRegionInter regionInter;


    /**
     * 查询下级代码数据
     * @param parentId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/level/{parentId}", method = RequestMethod.GET)
    public ResponseEntity findByParentId(@PathVariable("parentId") String parentId) throws Exception {
        Map params = new HashMap();
        params.put("parentId", parentId);
        return regionInter.findByCondition(params);
    }

    /**
     * 查询JSON树
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/json/tree", method = RequestMethod.GET)
    public ResponseEntity findTreeJSON() throws Exception {
        return regionInter.findTreeJSON();
    }
}
